package com.sky.mapper;


import com.sky.dto.ShoppingCartDTO;
import com.sky.entity.ShoppingCart;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

@Mapper
public interface ShoppingCartMapper {


    /**
     * 添加菜品和对应口味到购物车
     * @param shoppingCart
     */
    public void insert(ShoppingCart shoppingCart);




    /***
     * 查找购物车是否存在菜品或套餐
     * @param shoppingCart
     */


    List<ShoppingCart> findByShoppingCart(ShoppingCart shoppingCart);

    /**
     * 更新餐品数量
     * @param shoppingCart
     * @return
     */


//    @Update("update shopping_cart set number = #{number} where user_id = #{userId}")
    void updateNumber(ShoppingCart shoppingCart);

    /**
     * 删除商品
     * @param shoppingCart
     */
    void delete(ShoppingCart shoppingCart);


    /**
     * 查找商品数量
     * @param shoppingCart
     * @return
     */
    Integer findNumber(ShoppingCart shoppingCart);

    @Delete("delete from shopping_cart where user_id = #{userId}")
    void clean(Long userId);


}
